/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pojo.Thanhpho;
import until.MySqlDataAccessHelper;

/**
 *
 * @author Administrator
 */
public class ThanhPho_DAO {
    public static ArrayList<Thanhpho> layDanhSachDanhMuc(){
        ArrayList<Thanhpho>ds = new ArrayList<Thanhpho>();
        String sql=String.format("Select *from danhmuc");
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql);
        try {
            while (rs.next()) {                
                Thanhpho danhmuc= new Thanhpho();
                danhmuc.setId(rs.getInt("ID"));
                danhmuc.setNgayTao(rs.getDate("NgayTao"));
                danhmuc.setDaBat(rs.getInt("DaBat"));
                danhmuc.setTenThanhPho(rs.getString("TenThanhPho"));
                ds.add(danhmuc);
            }
        } catch (SQLException e) {
            System.out.print(e.getMessage());
        }
        helper.close();
        return ds;
    }
    
  
}
